home *** CD-ROM | disk | FTP | other *** search
- /* STARTUP PROCEDURE FOR TRANSLATED FORTRAN PROGRAMS */
-
- /* IMT 9Sep95 Modified for new conditional compile mechanism */
- #if ( defined(THINK_C) || defined(THINK_CPLUS) )
- #define TPM_F2C
- #endif
-
- /* IMT 9Sep95 Modified for new conditional compile mechanism */
- #if ( defined(SYMANTEC_C) || defined(SYMANTEC_CPLUS) )
- #define SPM_F2C
- #endif
-
- /* IMT 9Sep95 Modified for new conditional compile mechanism */
- #if ( !defined(MPW_CW_F2C) && defined(__MWERKS__) )
- #define CW_F2C
- #endif
-
- /* IMT 9Sep95 THINK Project Manager specific includes */
- #ifdef TPM_F2C
- #include <console.h>
- #endif
-
- /* IMT 9Sep95 Symantec Project Manager specific includes */
- #ifdef SPM_F2C
- #include <console.h>
- #endif
-
- /* IMT 9Sep95 CodeWarrior specific includes */
- #ifdef CW_F2C
- #include <console.h>
- #include <SIOUX.h>
- #endif
-
- /* IMT 9Sep95 MPW CodeWarrior specific includes */
- #ifdef MPW_CW_F2C
- #include <console.h>
- #endif
-
-
- /* IMT 12Apr96 Include files for adjusting the stack size in 68K */
- #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
- #if GENERATING68K
- #include <ConditionalMacros.h>
- #include <LowMem.h>
- #include <Memory.h>
- #endif /* GENERATING68K */
- #endif /* Macintosh C compilers */
-
-
- /* IMT 09Sep95 Prototypes for new functions that add multitasking */
- #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
- #ifdef __cplusplus
- extern "C" {
- #endif
- void InitMultiTask( long sliceInMicroSecs );
- void EndMultiTask( void );
- #ifdef __cplusplus
- }
- #endif
- #endif /* Macintosh C compilers */
-
-
- /* IMT 10Sep95 Declare jump buffer used to recover from exception exits & aborts */
- #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
- #include <setjmp.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- jmp_buf gRecoverToConsole;
- #ifdef __cplusplus
- }
- #endif
- #endif /* Macintosh C compilers */
-
-
- #include "stdio.h"
- #include "signal.h"
-
- #ifndef SIGIOT
- #ifdef SIGABRT
- #define SIGIOT SIGABRT
- #endif
- #endif
-
-
- #ifndef KR_headers
- #include "stdlib.h"
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef NO__STDC
- #define ONEXIT onexit
- extern void f_exit();
- #else
- #ifndef KR_headers
- extern void f_exit(void);
- #ifndef NO_ONEXIT
- #define ONEXIT atexit
- extern int atexit(void (*)(void));
- #endif
- #else
- #ifndef NO_ONEXIT
- #define ONEXIT onexit
- extern void f_exit();
- #endif
- #endif
- #endif
-
- #ifdef KR_headers
- extern void f_init(), sig_die();
- extern int MAIN__();
- #define Int /* int */
- #else
- extern void f_init(void), sig_die(char*, int);
- extern int MAIN__(void);
- #define Int int
- #endif
-
- static void sigfdie(Int n)
- {
- sig_die("Floating Exception", 1);
- }
-
-
- static void sigidie(Int n)
- {
- sig_die("IOT Trap", 1);
- }
-
- #ifdef SIGQUIT
- static void sigqdie(Int n)
- {
- sig_die("Quit signal", 1);
- }
- #endif
-
-
- static void sigindie(Int n)
- {
- sig_die("Interrupt", 0);
- }
-
- static void sigtdie(Int n)
- {
- sig_die("Killed", 0);
- }
-
- #ifdef SIGTRAP
- static void sigtrdie(Int n)
- {
- sig_die("Trace trap", 1);
- }
- #endif
-
-
-
- int xargc;
- char **xargv;
-
- #ifdef KR_headers
- main(argc, argv) int argc; char **argv;
- #else
- main(int argc, char **argv)
- #endif
- {
-
- /* IMT 12Apr96 Add conditional code to increase 68K stack size */
- /* Adjust the following #define as needed */
- #define kDesiredStackSize (40*1024L) /* 68K stack size set to 40K bytes */
- #if GENERATING68K && defined(kDesiredStackSize)
- if ( kDesiredStackSize > LMGetDefltStack() )
- {
- Ptr newApplLimit = GetApplLimit() - (kDesiredStackSize - LMGetDefltStack());
- SetApplLimit( newApplLimit );
- }
- #endif /* increase stack size */
-
- /* IMT 09Sep95 Add file re-direction and command-line arguments dialog */
- #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
- argc = ccommand( &argv );
- #endif /* Macintosh C compilers */
-
- /* IMT 14Sep95 Initialize multi-tasking code */
- #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
- InitMultiTask( 0 );
- #endif /* Multi-tasking code */
-
- xargc = argc;
- xargv = argv;
- signal(SIGFPE, sigfdie); /* ignore underflow, enable overflow */
- #ifdef SIGIOT
- signal(SIGIOT, sigidie);
- #endif
- #ifdef SIGTRAP
- signal(SIGTRAP, sigtrdie);
- #endif
- #ifdef SIGQUIT
- if(signal(SIGQUIT,sigqdie) == SIG_IGN)
- signal(SIGQUIT, SIG_IGN);
- #endif
- if(signal(SIGINT, sigindie) == SIG_IGN)
- signal(SIGINT, SIG_IGN);
- signal(SIGTERM,sigtdie);
-
- #ifdef pdp11
- ldfps(01200); /* detect overflow as an exception */
- #endif
-
- f_init();
- #ifndef NO_ONEXIT
- ONEXIT(f_exit);
- #endif
-
- /* IMT 10Sep95: Set-up for returning to console from exceptional exits and aborts */
- #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
- if ( setjmp(gRecoverToConsole) == 0 )
- #endif /* Macintosh C compilers */
-
- MAIN__();
-
- /* IMT 10Sep95: Close out multi-tasking code for CW, SPM, TPM */
- #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C)
- EndMultiTask();
- puts( "\nExecution complete.\n" );
- #endif /* Macintosh C compilers */
-
-
- #ifdef NO_ONEXIT
- f_exit();
- #endif
- exit(0); /* exit(0) rather than return(0) to bypass Cray bug */
- return 0; /* For compilers that complain of missing return values; */
- /* others will complain that this is unreachable code. */
- }
- #ifdef __cplusplus
- }
- #endif
-